package com.xuecheng.content.api;

import com.xuecheng.content.service.TeachPlanService;
import com.xuecheng.domain.dto.BindTeachplanMediaDto;
import com.xuecheng.domain.dto.SaveTeachplanDto;
import com.xuecheng.domain.dto.TeachPlanDto;
import com.xuecheng.domain.po.Teachplan;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Administrator
 */
@Slf4j
@RestController
public class TeachPlanController {

    @Resource
    private TeachPlanService teachPlanService;

    //查询课程计划
    @GetMapping("/teachplan/{courseId}/tree-nodes")
    public List<TeachPlanDto> getTreeNodes(@PathVariable Long courseId){
        return teachPlanService.findTeachplanTree(courseId);
    }

    @ApiOperation("课程计划创建或修改")
    @PostMapping("/teachplan")
    public void saveTeachplan(@Validated @RequestBody Teachplan saveTeachplanDto) {
        teachPlanService.saveTeachplan(saveTeachplanDto);
    }

    @ApiOperation("课程计划删除")
    @DeleteMapping("/teachplan/{teachplanId}")
    public void deleteTeachplan(@PathVariable Long teachplanId) {
            teachPlanService.deleteTeachplan(teachplanId);
    }


    @ApiOperation("课程计划排序")
    @PostMapping("/teachplan/{moveType}/{teachplanId}")
    public void orderByTeachplan(@PathVariable String moveType, @PathVariable Long teachplanId) {
        teachPlanService.orderByTeachplan(moveType, teachplanId);
    }
    @ApiOperation("课程计划关联媒资")
    @PostMapping("/teachplan/association/media")
    public void  associationMedia(@RequestBody BindTeachplanMediaDto bindTeachplanMediaDto){
        teachPlanService.associationMedia(bindTeachplanMediaDto);
    }
}
